home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 5 / CHASSIS_ / FINDERFI.C < prev    next >
Text File  |  1992-05-14  |  2KB  |  63 lines

  1. /************************************************************************************/
  2. /*    FinderFilesProc                                                                    */
  3. /*                                                                                    */
  4. /*    If the program was entered by the user's selecting one or more files, and then    */
  5. /*    using "Open" from the Finder menu (or command-O, or by dragging the file icons    */
  6. /*    into the application program icon (System 7)), open each of the files.            */
  7. /*                                                                                    */
  8. /*    If the program was entered by the user's selecting one or more files, and then    */
  9. /*    using "Print" from the Finder menu (or command-P), then for each file, open it,    */
  10. /*    print it, and close it.  After this has been done for each file, quit.            */
  11. /************************************************************************************/
  12.  
  13. #include "MyHeaders.h"
  14.  
  15. int FinderFilesProc ()
  16. {
  17.     int        FFRetCode = 0;
  18.  
  19.     UseResFile (initResRefNum);                        /* for H/P printer                */
  20.         
  21.     appIndex = 1;                                    /* initialize                    */
  22.     CountAppFiles (&appMessage, &appCount);            /* How many from Finder?        */
  23.     if (appCount > 0)                                /* if 1 or more                    */
  24.         {
  25.         if (appMessage == appOpen)                    /* if they are for "Open"        */
  26.             {
  27.             for (appIndex=1; appIndex <= appCount; appIndex++)    /* for each one        */
  28.                 {
  29.                 appMenuLong = ((0x010000 * FileMenuID) + OpenItem);    /* menu parm    */
  30.                 WorkRetCode = MenuProc (appMenuLong);    /* do "open" menu item        */
  31.                 if (WorkRetCode != 0)
  32.                     break;
  33.                 ClrAppFiles (appIndex);                    /* remove from Finder list    */
  34.                 }
  35.             }
  36.         else
  37.         if (appMessage == appPrint)                    /* if they are for "Print"        */
  38.             {
  39.             for (appIndex=1; appIndex <= appCount; appIndex++)    /* for each one        */
  40.                 {
  41.                 appMenuLong = ((0x010000 * FileMenuID) + OpenItem);    /* menu parm    */
  42.                 WorkRetCode = MenuProc (appMenuLong);    /* do "open" menu item        */
  43.                 if (WorkRetCode != 0)
  44.                     break;
  45.  
  46.                 appMenuLong = ((0x010000 * FileMenuID) + PrintItem); /* menu parm    */
  47.                 WorkRetCode = MenuProc (appMenuLong);    /* do "print" menu item        */
  48.                 if (WorkRetCode != 0)
  49.                     break;
  50.  
  51.                 appMenuLong = ((0x010000 * FileMenuID) + CloseItem); /* menu parm    */
  52.                 WorkRetCode = MenuProc (appMenuLong);    /* do "close" menu item        */
  53.  
  54.                 ClrAppFiles (appIndex);                    /* remove from Finder list    */
  55.                 }
  56.  
  57.             appMenuLong = ((0x010000 * FileMenuID) + QuitItem);        /* menu parm    */
  58.             WorkRetCode = MenuProc (appMenuLong);        /* do "quit" menu item        */
  59.             }
  60.         }
  61.  
  62.     return FFRetCode;
  63. }